﻿#pragma once
//
// receiver.cpp
// udp组播接收类
//
#include <array>
#include <iostream>
#include <string>
#include <functional>
#include <boost/asio.hpp>

class multicast_receiver
{
public:
    multicast_receiver(boost::asio::io_context& io_context
        , const boost::asio::ip::address& listen_address
        , const unsigned short& multicast_port
        , const boost::asio::ip::address& multicast_address
        , std::function<void (boost::system::error_code& ec
            , const char* data, std::size_t length
            , const boost::asio::ip::udp::endpoint& sender_endpoint)> receiver
        , size_t buffer_max = 1024
        );
    ~multicast_receiver();

private:
    void do_receive();
    multicast_receiver(const multicast_receiver&) = delete;
    struct multicast_receiver_impl;
    multicast_receiver_impl* impl{ nullptr };
};